<template>

  <div class="exception-page">
    <van-nav-bar
        title="商品兑换"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
        class="custom-nav"
    />
  </div>
<!--列表展示商品，能够兑换商品-->






</template>

<script setup>
import { ref } from 'vue'
import { GetProductList , ExchangeProduct,GetUserProductList} from "@/api/user";
import {ElMessage} from "element-plus";


const tableData = ref([])
const userTableData = ref([])

const onClickLeft = () => history.back()

//查询商品列表方法
function getProducts(){
  GetProductList().then(res => {
    if (res.data.code == 200000){
      tableData.value = res.data.data
    }
  })
}
//兑换商品
function exchangeProduct(row){
  ExchangeProduct(row.id).then(res => {
    if (res.data.code == 200000){
      ElMessage.success('兑换成功')
      getProducts()
      getUserProducts()
    }
  })
}
//查询用户商品列表
function getUserProducts(){
  GetUserProductList().then(res => {
    if (res.data.code == 200000){
      userTableData.value = res.data.data
    }
  })
}


</script>


<style scoped>

</style>